/*
 * ActionTurn.h
 *
 *  Created on: 09/giu/2011
 *      Author: lugas
 */

#ifndef ACTIONTURN_H_
#define ACTIONTURN_H_

#include "Aria.h"

/* Action that turns the robot away from obstacles detected by the
 * sonar. */
class ActionTurn: public ArAction {
public:
	// constructor, sets the turnThreshold, and turnAmount
	ActionTurn(double turnThreshold, double turnAmount, double initAngle, double finishAngle, char* name);
	// destructor, its just empty, we don't need to do anything
	virtual ~ActionTurn(void) {
	}
	;
	// fire, this is what the resolver calls to figure out what this action wants
	virtual ArActionDesired *fire(ArActionDesired currentDesired);
	// sets the robot pointer, also gets the sonar device, or deactivates this action if there is no sonar.
	virtual void setRobot(ArRobot *robot);

	double angleRotate;

	int myTurning; // -1 == left, 1 == right, 0 == none
protected:
	// this is to hold the sonar device form the robot
	ArRangeDevice *mySonar;
	// what the action wants to do; used by the action resover after fire()
	ArActionDesired myDesired;
	// distance at which to start turning
	double myTurnThreshold;
	// amount to turn when turning is needed
	double myTurnAmount;
	double myInitAngle;
	double myFinishAngle;

	// remember which turn direction we requested, to help keep turns smooth
};


#endif /* ACTIONTURN_H_ */
